var RightMenu = function(){
	var retsult ={
		item:null,
		Init:function(callback){
			
			var $menu = $('<div class="ppm-erp-menu"></div>');
			var $_ul = $('<ul></ul>');
			if(this.item != null){
				
				this.item.forEach(function(i,x,a){
					var $li = $('<li></li>');
					if(i.hasSplit == true){
						$li.addClass('ppm-erp-menu-splitline');
					}
					if(i.icon !=null){
						var $icon = $('<i class="ppm-erp-main-nav-logo iconfont"></i>').html(i.icon);
						$li.append($icon);
					}
					var $span = $('<span></span>').html(i.text);
					$li.append($span);
					$_ul.append($li);
					$li.click(function(){
						if(typeof(callback) == "function"){
							callback(i.text);
						}
					});
				});
				$menu.append($_ul);
				$('body').append($menu);
				//绑定右键
				$(document).contextmenu(function(e){
				    var winWidth = $(document).width();
				    var winHeight = $(document).height();
				    var posX = e.pageX;
				    var posY = e.pageY;
				    var menuWidth = $(".contextmenu").width();
				    var menuHeight = $(".contextmenu").height();
				    var secMargin = 10;
				    if(posX + menuWidth + secMargin >= winWidth
				    && posY + menuHeight + secMargin >= winHeight){
				      posLeft = posX - menuWidth - secMargin + "px";
				      posTop = posY - menuHeight - secMargin + "px";
				    }
				    else if(posX + menuWidth + secMargin >= winWidth){
				      posLeft = posX - menuWidth - secMargin + "px";
				      posTop = posY + secMargin + "px";
				    }
				    else if(posY + menuHeight + secMargin >= winHeight){
				      posLeft = posX + secMargin + "px";
				      posTop = posY - menuHeight - secMargin + "px";
				    }
				    else {
				      posLeft = posX + secMargin + "px";
				      posTop = posY + secMargin + "px";
				    }; 
				    $menu.css({
				    	"left": posLeft,
				    	"top": posTop
				    }).show();
				    $menu.show();
				    //取消默认右键菜单
					return false;
				});
				$(document).click(function(){
				   $menu.hide();
				});
			}


		}
		
	};
	return retsult;
	
}
